package lists_to_list;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.content.Context;
import android.telephony.TelephonyManager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

/*import com.example.androidhive.BASEACTIVITY;
import com.example.androidhive.Base_;
import com.example.androidhive.ItemListBaseAdapter1;
import com.example.androidhive.KlasaStatyczna;
import com.example.androidhive.R;
import com.example.androidhive.Wynik;*/
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

//import dane.Wspolrzedne;

public class Lista {
	private Activity aa;
	RRR sa(JSONObject c)  {
		try {
			return new RRR(c.getString("idnr"));
		} catch (JSONException e) {
			e.printStackTrace();
			return new RRR();
		}
		finally{
			new RRR(" ");
		}
	}
	/* private ArrayList<RRR> GetSearchResults2(){
		 	JSONObject json;
			JSONArray contacts = null;
			ArrayList<RRR> results = new ArrayList<RRR>();
			try {
				contacts = Wynik.json.getJSONArray("products");
				for (int i = 0; i < contacts.length(); i++)
					results.add(sa(contacts.getJSONObject(i)));
			} catch (JSONException e) {
				e.printStackTrace();
			}
	    	return results;
	    }*/
/*	 private void initiatePopupWindow() {
			try {
			LayoutInflater inflater = (LayoutInflater) Activity.this
			.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			layout = inflater.inflate(R.layout.screen_popup,
			(ViewGroup) aa.findViewById(R.id.popup_element));
			pwindo = new PopupWindow(layout, 300, 370, true);
			pwindo.showAtLocation(layout, Gravity.CENTER, 0, 0);
			Button aaa =(Button) layout.findViewById(R.id.zatwierdz);
				aaa.setOnClickListener(new View.OnClickListener() {
					@Override
					public void onClick(View view) {
						  Map<String,String> mma=new HashMap<String,String>();
						  mma.put("nazwa", "mm");
						  				Base_ aa=new Base_(aa.this,mma,aa.getApplicationContext());
						  				aa.setAaa(new String[]{"zat"});
				  				aa.execute();
				  				Toast.makeText(aa.getBaseContext(), "AAAAA", Toast.LENGTH_SHORT).show();
				  				try{
				  					Thread.sleep(3000);
				  				}
				  				catch(Exception e){}
					}
				});
			btnClosePopup = (Button) layout.findViewById(R.id.btn_close_popup);
			btnClosePopup.setOnClickListener(cancel_button_click_listener);
			
			//
			TelephonyManager telemamanger = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
		    String getSimSerialNumber = telemamanger.getSimSerialNumber(); 
		 
			TextView chkIos = (TextView) layout.findViewById(R.id.txtView);
			chkIos.setText(String.valueOf(getSimSerialNumber));

			} catch (Exception e) {
			e.printStackTrace();
			}
			}*/
	 GoogleMap x;
	/*public Lista(Activity a,GoogleMap aaa){
		x=aaa;
		aa=a;
		ArrayList<RRR> image_details = GetSearchResults2();Wynik.parsujlokalizacje();
		 final ListView lv1 = (ListView) a.findViewById(R.id.listV_main);
	     lv1.setAdapter(new ItemListBaseAdapter1(a, image_details));
	      lv1.setOnItemClickListener(new OnItemClickListener() {
	     	@Override
	     	public void onItemClick(AdapterView<?> a, View v, int position, long id) { 
	     		// initiatePopupWindow();
	     		Object o = lv1.getItemAtPosition(position);
	         	RRR obj_itemDetails = (RRR)o;
	         	Iterator<Wspolrzedne> iw=(KlasaStatyczna.getWsp()).iterator();
	         	while(iw.hasNext()){
	         		Wspolrzedne rr =iw.next();
	         		if(rr.getNazwa()==obj_itemDetails.getWartosc()){
	         			LatLng g=new LatLng(Double.valueOf(rr.getA()),Double.valueOf(rr.getB()));
	         		x.moveCamera(CameraUpdateFactory.newLatLngZoom(g, 5));
	         		MarkerOptions markerOptions = new MarkerOptions();
					markerOptions.position(g);
					markerOptions.title(rr.getNazwa());
					x.clear();
					//x.animateCamera(CameraUpdateFactory.newLatLng(g,5));
					x.addMarker(markerOptions);}
	         		//Toast.makeText(aa, "You have chosen== : " + obj_itemDetails.getWartosc() , Toast.LENGTH_LONG).show();}
	         	}
	     	}  
	     });
		}*/
}
